home *** CD-ROM | disk | FTP | other *** search
/ QuickTime 2.0 Developer Kit / QuickTime 2.0 Developer Kit.iso / mac / MAC / Programming Stuff / Sample Code / Music Architecture / Embedding Instruments / BigEasy / OneWindow.c < prev   
Encoding:
C/C++ Source or Header  |  1994-08-17  |  3.8 KB  |  216 lines  |  [TEXT/KAHL]

  1. /*
  2.     File:        OneWindow.c
  3.  
  4.     Contains:    xxx put contents here xxx
  5.  
  6.     Written by:    xxx put writers here xxx
  7.  
  8.     Copyright:    © 1991-1992, 1994 by Apple Computer, Inc., all rights reserved.
  9.  
  10.     This file is used in these builds: Warhol
  11.  
  12.     Change History (most recent first):
  13.  
  14.          <7>     17-8-94    dvb        Big Easy Printing, and various tidiness
  15.          <5>      1/7/93    dvb        Built in window-copy command.
  16.          <4>    11/12/91    dvb        General fixation
  17.          <3>     7/18/91    dvb        More.
  18.          <2>     4/25/91    JB        
  19.  
  20.     To Do:
  21. */
  22.  
  23. /*
  24.  * file: OneWindow.c
  25.  *
  26.  * started 7 July 1988 09:34
  27.  * david van brink
  28.  *
  29.  * A starting point for BigEasy programs
  30.  *
  31.  */
  32.  
  33.  
  34. /*--------------------------
  35.     Inclusions
  36. --------------------------*/
  37.  
  38. #include <QuickDraw.h>
  39. #include <Memory.h>
  40. #include <Windows.h>
  41. //#include <OSUtils.h>
  42.  
  43. #include "BigEasy2.h"
  44. #include "BigEasyUtils.h"
  45. #include "BigEasyGrafish.h"
  46.  
  47. /*--------------------------
  48.     Limits and Konstants
  49. --------------------------*/
  50. enum
  51.     {
  52.     mFirstDocOnly = 100,
  53.     mClose,
  54.     mLastDocOnly,
  55.     mOpen
  56.     };
  57.  
  58. typedef struct
  59.     {
  60.     WindowPtr w;
  61.     } Globals;
  62.  
  63. Globals *g = nil;
  64.  
  65. /*--------------------------
  66.     Prototypes
  67. --------------------------*/
  68. static void DrawDoc(short n);
  69. static void ClickDoc(short n,Point p,short mods);
  70. static void KeyDoc(short n,short key,short code,short mods);
  71. static void IdleDoc(short n, Boolean front);
  72. static void GoAwayDoc(short n);
  73. static void ActivateDoc(short n);
  74. static void DeactivateDoc(short n);
  75. static void LetsQuit(short n,short menuItem,short menuRef);
  76. static void OpenWindow(short n,short menuItem,short menuRef);
  77. static void InitVars(void);
  78.  
  79.  
  80. /*--------------------------
  81.     Computer Programs
  82. --------------------------*/
  83.  
  84.  
  85. #define kHeaderHeight 17
  86. #define kWindowWidth 200
  87. #define kWindowHeight 100
  88.  
  89. void DrawDoc(short n)
  90. /*
  91.  * Draws the window.
  92.  */
  93.     {
  94.     #pragma unused (n)
  95.     Rect r;
  96.  
  97.     GoBW();
  98.     EraseRect(&qd.thePort->portRect);
  99.     TextSize(9);
  100.     MoveTo(10,12);
  101.     DrawString("\pThis is the window");
  102.     MoveTo(0,kHeaderHeight-3);
  103.     Line(qd.thePort->portRect.right,0);
  104.     MoveTo(0,kHeaderHeight-1);
  105.     Line(qd.thePort->portRect.right,0);
  106.  
  107.  
  108.     RGBFore(50000,50000,65535);
  109.     r = qd.thePort->portRect;
  110.     r.top = kHeaderHeight;
  111.     PaintRect(&r);
  112.     GoBW();
  113.     }
  114.  
  115.  
  116. void ClickDoc(short n,Point p,short mods)
  117. /*
  118.  * Come here for a click in the window.
  119.  */
  120.     {
  121.     #pragma unused (n,p,mods)
  122.     SysBeep(1);
  123.     }
  124.  
  125.  
  126. void KeyDoc(short n,short key,short code,short mods)
  127.     {
  128.     #pragma unused (n,key,code,mods)
  129.     }
  130.  
  131. void IdleDoc(short n, Boolean front)
  132.     {
  133.     #pragma unused (n,front)
  134.     }
  135.  
  136. void GoAwayDoc(short n)
  137. /*
  138.  * Close that window...
  139.  */
  140.     {
  141.     UninstallWindow(n);
  142.     }
  143.  
  144. void ActivateDoc(short n)
  145.     {
  146.     #pragma unused (n)
  147.  
  148.     SetMenuItemRange(mFirstDocOnly,mLastDocOnly,1,0);
  149.     SetMenuItem(mOpen,-1,0,0,nil);                /* disable "Open" menu item        */
  150.     }
  151.  
  152. void DeactivateDoc(short n)
  153.     {
  154.     #pragma unused (n)
  155.  
  156.     SetMenuItemRange(mFirstDocOnly,mLastDocOnly,-1,0);
  157.     SetMenuItem(mOpen,1,0,0,nil);                /* enable "Open" menu item        */
  158.     }
  159.  
  160. void LetsQuit(short n,short menuItem,short menuRef)
  161.     {
  162.     #pragma unused (n,menuItem,menuRef)
  163.     gQuitApp++;
  164.     }
  165.  
  166. void OpenWindow(short n,short menuItem,short menuRef)
  167.     {
  168.     #pragma unused (n,menuItem,menuRef)
  169.     Rect r;
  170.     WindowPtr w;
  171.  
  172.     SetRect(&r,0,0,kWindowWidth,kWindowHeight);
  173.     OffsetRect(&r,30,50);
  174.  
  175.     g->w = InstallWindow(1,"\pWindow",&r,0,wCopyDraw + wGrowable + wPrintDraw,
  176.             DrawDoc,ClickDoc,KeyDoc,GoAwayDoc,
  177.             ActivateDoc,DeactivateDoc,IdleDoc);
  178.     }
  179.  
  180. void InitVars()
  181. /*
  182.  * Called once at startup: yes, it
  183.  * inits the vars.
  184.  */
  185.     {
  186.     gMenuNeedsCmdKey = false;
  187.  
  188.     g = (Globals *)NewPtrClear(sizeof(Globals));
  189.     }
  190.  
  191. void Bootstrap()
  192.     {
  193.     InitVars();
  194.  
  195. /*** File Menu ***/
  196.     InstallMenu("\pFile",nil,0);
  197.     InstallMenuItem("\pOpen/O",OpenWindow,mOpen);
  198.     InstallMenuItem("\pClose/W",(void *)GoAwayDoc,-mClose);
  199.     InstallMenuItem("\p(-",nil,0);
  200.     InstallPrintItems(nil,nil);
  201.     InstallMenuItem("\p(-",nil,0);
  202.     InstallQuitItem(LetsQuit,0);
  203.  
  204. /*** Edit Menu ***/
  205.     InstallEditMenu(nil,nil,nil,nil,nil);
  206.  
  207.     OpenWindow(0,0,0);
  208.     }
  209.  
  210. void Hatstrap()
  211. /*
  212.   * clean up
  213.   */
  214.     {
  215.     }
  216.